import QtQuick 2.0

import QtQuick.Controls 2.12
import QtQuick.Layouts 1.12

Item {
    width: buttonFile.width + buttonDown.width
    height: 35
    property var labelMsg: null

    MyToolButton{
        id: buttonFile
        x: 0
        y: 0
        icon.source: "qrc:/image/myMenu.svg"
        width: implicitWidth
        height: parent.height
        onClicked: {
            myMenuFiles.popup(this, x, y+parent.height)
            myMenuAll.close()
        }
        display: AbstractButton.TextBesideIcon
        text: "Files"
    }

    MyToolButton {
        id: buttonDown
        width:17
        height: parent.height
        anchors.left: buttonFile.right
        anchors.leftMargin: 0
        icon.source: "qrc:/image/myDown.svg"

        onClicked: {
            myMenuAll.popup(parent, parent.x +10, parent.height)
            myMenuFiles.close()
        }
    }

    Menu{
        id:myMenuFiles
        title:"Files"
        MenuItem{action:actionFileOpen}
        MenuItem{action:actionFileClose}
    }

    Menu{
        id:myMenuAll
        title:"All"
        visible: false
        MenuItem{action:actionStart}
        MenuItem{action:actionInsert}
        MenuItem{action:actionView}
    }
    Action{
        id:actionFileOpen
        text: "&Open File"
        onTriggered: {
            console.log("To do -Open File")
            labelMsg.text="To do -Open File"
        }
    }

    Action{
        id:actionFileClose
        text: "&Close File"
        onTriggered: {
            console.log("To do -Close file")
            labelMsg.text="To do -Close file"
        }
    }

    Action{
        id:actionStart
        text: "&Start"
        onTriggered: {
            console.log("To do -Start")
            labelMsg.text="To do -Start"
        }
    }

    Action{
        id:actionInsert
        text: "&Insert"
        onTriggered: {
            console.log("To do -Insert")
            labelMsg.text = "To do -Insert"
        }
    }

    Action{
        id:actionView
        text: "&View"
        onTriggered: {
            console.log("To do -View")
            labelMsg.text="To do -View"
        }
    }
}
